package tp.pr4;

import tp.pr4.items.Item;
import tp.pr4.items.ItemContainer;

public class Place {
	private java.lang.String name;
    private boolean isSpaceShip;
    private java.lang.String description;
    private ItemContainer placeInventory;
    


	public Place(java.lang.String name,
		     boolean isSpaceShip,
		     java.lang.String description)
	{
		this.name=name;
		this.isSpaceShip=isSpaceShip;
		this.description=description;
		placeInventory= new ItemContainer();
	}

	public boolean isSpaceship()
	{
	 return this.isSpaceShip;
	}
	
	public java.lang.String toString()
	{
		String LINE_SEPARATOR = System.getProperty("line.separator");
		if(placeInventory.numberOfItems()>0)
		return (this.name + 
				LINE_SEPARATOR + 
				this.description +
				LINE_SEPARATOR + 
				"The place contains these objects:"+
				LINE_SEPARATOR + 
				placeInventory.toString());
		else
			return(this.name + 
				LINE_SEPARATOR + 
				this.description +
				LINE_SEPARATOR + 
				"The place is empty. There are no objects to pick");
	}	
	
	public boolean existItem(java.lang.String id)
	{
		return this.placeInventory.containsItem(id);
	}
	
	public Item pickItem(java.lang.String id)
	{
	 return placeInventory.pickItem(id);	
	}
	
	public boolean addItem(Item it)
	{
		return placeInventory.addItem(it);
	}
	
	public boolean dropItem(Item it)
	{
		return placeInventory.addItem(it);
	}
}
